package org.gap.dao;

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.gap.domain.Adresses;

import org.skyway.spring.util.dao.AbstractJpaDao;

import org.springframework.dao.DataAccessException;

import org.springframework.stereotype.Repository;

import org.springframework.transaction.annotation.Transactional;

/**
 * DAO to manage Adresses entities.
 * 
 */
@Repository("AdressesDAO")
@Transactional
public class AdressesDAOImpl extends AbstractJpaDao<Adresses> implements
		AdressesDAO {

	/**
	 * Set of entity classes managed by this DAO.  Typically a DAO manages a single entity.
	 *
	 */
	private final static Set<Class<?>> dataTypes = new HashSet<Class<?>>(Arrays.asList(new Class<?>[] { Adresses.class }));

	/**
	 * EntityManager injected by Spring for persistence unit 
	 *
	 */
	@PersistenceContext(unitName = "")
	private EntityManager entityManager;

	/**
	 * Instantiates a new AdressesDAOImpl
	 *
	 */
	public AdressesDAOImpl() {
		super();
	}

	/**
	 * Get the entity manager that manages persistence unit 
	 *
	 */
	public EntityManager getEntityManager() {
		return entityManager;
	}

	/**
	 * Returns the set of entity classes managed by this DAO.
	 *
	 */
	public Set<Class<?>> getTypes() {
		return dataTypes;
	}

	/**
	 * JPQL Query - findAdressesByAddDateCreationAfter
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddDateCreationAfter(java.util.Calendar addDateCreation) throws DataAccessException {

		return findAdressesByAddDateCreationAfter(addDateCreation, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddDateCreationAfter
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddDateCreationAfter(java.util.Calendar addDateCreation, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddDateCreationAfter", startResult, maxRows, addDateCreation);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByPrimaryKey
	 *
	 */
	@Transactional
	public Adresses findAdressesByPrimaryKey(Integer addAdresse) throws DataAccessException {

		return findAdressesByPrimaryKey(addAdresse, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByPrimaryKey
	 *
	 */

	@Transactional
	public Adresses findAdressesByPrimaryKey(Integer addAdresse, int startResult, int maxRows) throws DataAccessException {
		try {
			return executeQueryByNameSingleResult("findAdressesByPrimaryKey", addAdresse);
		} catch (NoResultException nre) {
			return null;
		}
	}

	/**
	 * JPQL Query - findAdressesByAddTypeVoie
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddTypeVoie(String addTypeVoie) throws DataAccessException {

		return findAdressesByAddTypeVoie(addTypeVoie, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddTypeVoie
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddTypeVoie(String addTypeVoie, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddTypeVoie", startResult, maxRows, addTypeVoie);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddLigne1
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddLigne1(String addLigne1) throws DataAccessException {

		return findAdressesByAddLigne1(addLigne1, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddLigne1
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddLigne1(String addLigne1, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddLigne1", startResult, maxRows, addLigne1);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddTopNpaiContaining
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddTopNpaiContaining(String addTopNpai) throws DataAccessException {

		return findAdressesByAddTopNpaiContaining(addTopNpai, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddTopNpaiContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddTopNpaiContaining(String addTopNpai, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddTopNpaiContaining", startResult, maxRows, addTopNpai);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddDateModificationBefore
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddDateModificationBefore(java.util.Calendar addDateModification) throws DataAccessException {

		return findAdressesByAddDateModificationBefore(addDateModification, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddDateModificationBefore
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddDateModificationBefore(java.util.Calendar addDateModification, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddDateModificationBefore", startResult, maxRows, addDateModification);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAllAdressess
	 *
	 */
	@Transactional
	public Set<Adresses> findAllAdressess() throws DataAccessException {

		return findAllAdressess(-1, -1);
	}

	/**
	 * JPQL Query - findAllAdressess
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAllAdressess(int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAllAdressess", startResult, maxRows);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddLigne3Containing
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddLigne3Containing(String addLigne3) throws DataAccessException {

		return findAdressesByAddLigne3Containing(addLigne3, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddLigne3Containing
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddLigne3Containing(String addLigne3, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddLigne3Containing", startResult, maxRows, addLigne3);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddDateModificationAfter
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddDateModificationAfter(java.util.Calendar addDateModification) throws DataAccessException {

		return findAdressesByAddDateModificationAfter(addDateModification, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddDateModificationAfter
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddDateModificationAfter(java.util.Calendar addDateModification, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddDateModificationAfter", startResult, maxRows, addDateModification);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddAdresse
	 *
	 */
	@Transactional
	public Adresses findAdressesByAddAdresse(Integer addAdresse) throws DataAccessException {

		return findAdressesByAddAdresse(addAdresse, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddAdresse
	 *
	 */

	@Transactional
	public Adresses findAdressesByAddAdresse(Integer addAdresse, int startResult, int maxRows) throws DataAccessException {
		try {
			return executeQueryByNameSingleResult("findAdressesByAddAdresse", addAdresse);
		} catch (NoResultException nre) {
			return null;
		}
	}

	/**
	 * JPQL Query - findAdressesByAddLigne1Containing
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddLigne1Containing(String addLigne1) throws DataAccessException {

		return findAdressesByAddLigne1Containing(addLigne1, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddLigne1Containing
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddLigne1Containing(String addLigne1, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddLigne1Containing", startResult, maxRows, addLigne1);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddLigne2
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddLigne2(String addLigne2) throws DataAccessException {

		return findAdressesByAddLigne2(addLigne2, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddLigne2
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddLigne2(String addLigne2, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddLigne2", startResult, maxRows, addLigne2);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddBureauDistribContaining
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddBureauDistribContaining(String addBureauDistrib) throws DataAccessException {

		return findAdressesByAddBureauDistribContaining(addBureauDistrib, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddBureauDistribContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddBureauDistribContaining(String addBureauDistrib, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddBureauDistribContaining", startResult, maxRows, addBureauDistrib);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddBureauDistrib
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddBureauDistrib(String addBureauDistrib) throws DataAccessException {

		return findAdressesByAddBureauDistrib(addBureauDistrib, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddBureauDistrib
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddBureauDistrib(String addBureauDistrib, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddBureauDistrib", startResult, maxRows, addBureauDistrib);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddDateCreationBefore
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddDateCreationBefore(java.util.Calendar addDateCreation) throws DataAccessException {

		return findAdressesByAddDateCreationBefore(addDateCreation, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddDateCreationBefore
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddDateCreationBefore(java.util.Calendar addDateCreation, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddDateCreationBefore", startResult, maxRows, addDateCreation);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddDateModification
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddDateModification(java.util.Calendar addDateModification) throws DataAccessException {

		return findAdressesByAddDateModification(addDateModification, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddDateModification
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddDateModification(java.util.Calendar addDateModification, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddDateModification", startResult, maxRows, addDateModification);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddTypeVoieContaining
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddTypeVoieContaining(String addTypeVoie) throws DataAccessException {

		return findAdressesByAddTypeVoieContaining(addTypeVoie, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddTypeVoieContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddTypeVoieContaining(String addTypeVoie, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddTypeVoieContaining", startResult, maxRows, addTypeVoie);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddLigne3
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddLigne3(String addLigne3) throws DataAccessException {

		return findAdressesByAddLigne3(addLigne3, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddLigne3
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddLigne3(String addLigne3, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddLigne3", startResult, maxRows, addLigne3);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddLigne2Containing
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddLigne2Containing(String addLigne2) throws DataAccessException {

		return findAdressesByAddLigne2Containing(addLigne2, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddLigne2Containing
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddLigne2Containing(String addLigne2, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddLigne2Containing", startResult, maxRows, addLigne2);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddTopNpai
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddTopNpai(String addTopNpai) throws DataAccessException {

		return findAdressesByAddTopNpai(addTopNpai, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddTopNpai
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddTopNpai(String addTopNpai, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddTopNpai", startResult, maxRows, addTopNpai);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * JPQL Query - findAdressesByAddDateCreation
	 *
	 */
	@Transactional
	public Set<Adresses> findAdressesByAddDateCreation(java.util.Calendar addDateCreation) throws DataAccessException {

		return findAdressesByAddDateCreation(addDateCreation, -1, -1);
	}

	/**
	 * JPQL Query - findAdressesByAddDateCreation
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Adresses> findAdressesByAddDateCreation(java.util.Calendar addDateCreation, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAdressesByAddDateCreation", startResult, maxRows, addDateCreation);
		return new LinkedHashSet<Adresses>(query.getResultList());
	}

	/**
	 * Used to determine whether or not to merge the entity or persist the entity when calling Store
	 * @see store
	 * 
	 *
	 */
	public boolean canBeMerged(Adresses entity) {
		return true;
	}
}
